#include <QFile>
#include <QRegExp>
#include <QDebug>

#include "rename.h"

Rename::Rename(QString filename)
{
    originname  = filename;
    
    int length  = filename.length();
    int postion = filename.lastIndexOf('.');
    basename    = filename.left(postion);
    suffix      = filename.right(length-postion);
}

void Rename::clear() 
{
    QRegExp regexp("^[0-9a-zA-Z]");
    basename.replace(regexp, "");
}

void Rename::replace(int postion, int n, const QString &after)
{
    basename.replace(postion, n, after);
}

void Rename::replace(const QString &before, const QString &after)
{
    basename.replace(before, after);
}

void Rename::remove(int postion, int n)
{
    basename.remove(postion, n);
}

void Rename::remove(const QString str)
{
    basename.remove(str);
}

void Rename::insert(int postion, const QString &str) 
{
    basename.insert(postion, str);
}

void Rename::after(const QString &str) 
{
    int len = basename.length();
    basename.insert(len, str);
}

void Rename::swap(const QString &after)
{
    basename = after;
}

void Rename::swap_suffix(const QString &after)
{
    suffix  = after;
}

QString Rename::filename() const
{
    return basename + suffix;
}

QString Rename::getbasename() const
{
    return basename;
}

